import subprocess
import os
#import sys
#sys.path.append('C:/Users/tfree/Documents/UMMS/Python/UDFs')
#import custom2

#OPTIONS
invert = 'True'#Change invert to str 'True' if calculating onset of reductions in signal
output_folder = 'C:/Users/Tim/Desktop/Temp_Codespace/Novelty_Seeking/output_folder/'
input_folder = 'C:/Users/Tim/Desktop/Temp_Codespace/Novelty_Seeking/input_folder/'
udfs = 'C:/Users/Tim/Desktop/Temp_Codespace/Novelty_Seeking'
#params={'output_folder': output_string, 'input_folder': input_string}
#custom2.make_ctl_file(params, 'novelty_peak_onset_wrap.ctl')
#params=custom2.use_ctl_file()
#output_folder=params['output_folder']
#input_folder = params['input_folder']

folder_paths = []

for filename in os.listdir(input_folder):
	folder_paths.append(filename)
	
for filename in folder_paths:
	print('Processing: ' + filename + '...')
	input_handle = input_folder+filename#Change to name of the desired input file
	save_handle = output_folder+filename#+'.csv' #Change to name for labeling output files
	subprocess.call(['python','novelty_peak_onset_estimation.py',input_handle, invert, save_handle, udfs])
	subprocess.call(['python','novelty_peak_onset_calcs.py','onset_dict.pkl', 'time.pkl', 'event_list.pkl'])
	subprocess.call(['python','novelty_peak_onset_signal_mean.py','time.pkl','event_list.pkl','onset_dict.pkl','event_num_check.pkl'])
	subprocess.call(['python','novelty_peak_onset_output.py', save_handle, 'onset_dict.pkl', 'onset_calc_dict.pkl', 'outlier_dict.pkl', 'time.pkl','smooth_events.pkl','signal_mean_dict.pkl','auc_dict.pkl'])

print('Done')
